package utils

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

// 接口错误返回函数
func GinError(ctx *gin.Context, err error, message string, code int) (isErr bool) {
	isErr = false
	if err != nil {
		ctx.JSON(http.StatusOK, gin.H{
			"code": code,
			"msg":  message,
			//"data":    "",
		})
		isErr = true
	}
	return
}

// 接口返回
func GinReply(ctx *gin.Context, message string, code int, data interface{}) {
	ctx.JSON(http.StatusOK, gin.H{
		"code": code,
		"msg":  message,
		"data": data,
	})
}
